]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
network: remove the vpn request when it's serviced
authorLubomir Rintel <lkundrak@v3.sk>
Wed, 6 Dec 2017 15:55:15 +0000 (16:55 +0100)
committerLubomir Rintel <lkundrak@v3.sk>
Fri, 12 Jan 2018 10:48:52 +0000 (11:48 +0100)
The native agent already forgets about the request at the point it's
serviced and the further attempt to use it (e.g. cancel it when the screen
is locked) will trigger an assertion failure:

  ** (gnome-shell:30862): CRITICAL **: shell_network_agent_respond: assertion 'request != NULL' failed

https://bugzilla.gnome.org/show_bug.cgi?id=789811

js/ui/components/networkAgent.js

index 5faabb65b1c8a2d127a525a480af177915d243d3..a591d05e9e0ef272a5b9e082bc0f2be6e6285436 100644 (file)
@@ -8,6 +8,7 @@ const Lang = imports.lang;
 const NM = imports.gi.NM;
 const Pango = imports.gi.Pango;
 const Shell = imports.gi.Shell;
+const Signals = imports.signals;
 const St = imports.gi.St;
 
 const Config = imports.misc.config;
@@ -413,7 +414,9 @@ var VPNRequestHandler = new Lang.Class({
         if (this._destroyed)
             return;
 
-        GLib.source_remove(this._childWatch);
+        this.emit('destroy');
+        if (this._childWatch)
+            GLib.source_remove(this._childWatch);
 
         this._stdin.close(null);
         // Stdout is closed when we finish reading from it
@@ -540,6 +543,7 @@ var VPNRequestHandler = new Lang.Class({
                 logError(e, 'error while reading VPN plugin output keyfile');
 
                 this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR);
+                this.destroy();
                 return;
             }
         }
@@ -550,6 +554,7 @@ var VPNRequestHandler = new Lang.Class({
             this._shellDialog.open(global.get_current_time());
         } else {
             this._agent.respond(this._requestId, Shell.NetworkAgentResponse.CONFIRMED);
+            this.destroy();
         }
     },
 
@@ -570,9 +575,11 @@ var VPNRequestHandler = new Lang.Class({
             logError(e, 'internal error while writing connection to helper');
 
             this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR);
+            this.destroy();
         }
     },
 });
+Signals.addSignalMethods(VPNRequestHandler.prototype);
 
 var NetworkAgent = new Lang.Class({
     Name: 'NetworkAgent',
@@ -740,7 +747,11 @@ var NetworkAgent = new Lang.Class({
             return;
         }
 
-        this._vpnRequests[requestId] = new VPNRequestHandler(this._native, requestId, binary, serviceType, connection, hints, flags);
+        let vpnRequest = new VPNRequestHandler(this._native, requestId, binary, serviceType, connection, hints, flags);
+        vpnRequest.connect('destroy', Lang.bind(this, function() {
+            delete this._vpnRequests[requestId];
+        }));
+        this._vpnRequests[requestId] = vpnRequest;
     },
 
     _buildVPNServiceCache: function() {